<template>
  <div id="app">
    <el-container>
      <el-header>
        <el-menu :default-active="activePage" class="el-menu-demo" mode="horizontal" @select="changePage">
          <el-menu-item v-for="page in pages" :key="'page-'+page.name" :index="page.name">
            {{ page.name }}
          </el-menu-item>
        </el-menu>
      </el-header>
      <el-main>
        <router-view/>
      </el-main>
    </el-container>

  </div>
</template>

<script>
  import Routes, {RoutesMap} from "./router";

  export default {
    name: 'App',
    components: {},
    data() {
      return {
        pages: Routes,
        activePage: "0"
      };
    },
    methods: {
      changePage(name) {
        let page = RoutesMap[name];
        if (this.$route.name === page.name) {
          return;
        }
        this.$router.push(page.path);
      }
    }
  }
</script>

<style>
  @font-face {
    font-family: 'webfont';
    font-display: swap;
    src: url('//at.alicdn.com/t/webfont_bgmomd40xwn.eot'); /* IE9*/
    src: url('//at.alicdn.com/t/webfont_bgmomd40xwn.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('//at.alicdn.com/t/webfont_bgmomd40xwn.woff2') format('woff2'),
    url('//at.alicdn.com/t/webfont_bgmomd40xwn.woff') format('woff'), /* chrome、firefox */ url('//at.alicdn.com/t/webfont_bgmomd40xwn.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('//at.alicdn.com/t/webfont_bgmomd40xwn.svg#Alibaba-PuHuiTi-Regular') format('svg'); /* iOS 4.1- */
  }


  #app {
    font-family: Avenir, Helvetica, Arial, sans-serif, webfont;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: #2c3e50;
  }
</style>
